package com.lap.framework.generator.domain.template.strategy;

import com.lap.framework.generator.application.assembler.Transformer;
import com.lap.framework.generator.domain.TemplateModel;
import com.lap.framework.generator.domain.template.CodeContext;
import com.lap.framework.generator.domain.template.CodeTemplate;
import com.lap.framework.generator.domain.valueobject.CodeType;
import java.util.ArrayList;
import java.util.List;

public class Message implements CodeTemplate<String> {

  @Override
  public CodeType getType() {
    return CodeType.MESSAGE;
  }

  @Override
  public List<String> generate(CodeContext context) {
    TemplateModel model = Transformer.transform(context.tableMeta(), context.envConfig());
    List<String> result = new ArrayList<>();
    model.getFields().forEach(item -> result.addAll(item.getErrorMessages()));
    return result;
  }
}
